package com.baimawangzi.recovery.servlet.courier;

import com.baimawangzi.recovery.service.impl.CourierServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/courierdelete.do")//这里的/不能少否则部署错误相当恶心
public class CourierDeleteServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        CourierServiceImpl courierService = new CourierServiceImpl();
        //解析url参数
        int id = Integer.parseInt(req.getParameter("id"));
        System.out.println(id);
        int a = courierService.delete(id);
        if(a>0){
            req.setAttribute("msg","删除快递员成功");
        }
        else {
            req.setAttribute("msg","删除快递员失败");
        }
        try {
            req.getRequestDispatcher("courierlist.do").forward(req,resp);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
